﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SWENAssignment
{
    public partial class serachStaffScuccessfullyUpdateVersion : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblStaffId.Text = (string)Session["staffId"];
            if (!Page.IsPostBack)
            {
                staffDetails s = DBmanager.getByStaffId(lblStaffId.Text);
                //lblStaffId.Text = s.StaffId;
                tbxAddress.Text = s.address;
                tbxContactNo.Text = s.ContactNumber.ToString();
                ddlDutyType.SelectedValue = s.dutyType;
            }
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
           staffDetails updateStaff = new staffDetails();
           updateStaff.StaffId = lblStaffId.Text;
           updateStaff.address = tbxAddress.Text;
            updateStaff.ContactNumber = Convert.ToInt32(tbxContactNo.Text);
            updateStaff.dutyType = ddlDutyType.SelectedValue;

            if(DBmanager.updateStaffProfile(updateStaff)==1)
            {
                Session["staffId"] = updateStaff.StaffId;
                Server.Transfer("updateFinalStaffSuccessfully.aspx");
            }
            
            else
            {
                lblStatus.Text = "Updating is unsuccessful!";
            }
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Server.Transfer("updateStaffProfile1.aspx?");
        }
    }
}

 